package com.briup.cms.web.controller;

import com.briup.cms.bean.Comment;
import com.briup.cms.bean.Test;
import com.briup.cms.bean.extend.CommentExtend;
import com.briup.cms.service.ICommentService;
import com.briup.cms.service.ITestService;
import com.briup.cms.utils.Message;
import com.briup.cms.utils.MessageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.sql.ClientInfoStatus;
import java.util.List;

@Api(description = "评论模块接口")
@RestController
@RequestMapping("/cms_Comment")
public class CommentController {

    @Autowired
    private ICommentService commentService;

    @GetMapping("selectAllWithArticle")
    public  Message findAllWithArticle(){
        List<CommentExtend> list = commentService.selectAllWithArticle();
        return MessageUtil.success(list);
    }

    @GetMapping("selectAllWithUser")
    public Message selectAllWithUser(){
        List<CommentExtend> list =commentService.selectAllWithUser();
        return MessageUtil.success(list);
    }
    @ApiOperation("查询所有")
    @GetMapping("findAll")
    public Message findAll(){
        List<Comment> list=commentService.findAll();
        return MessageUtil.success(list);
    }

    @ApiOperation("保存或更新")
    @PostMapping("saveOrUpdate")
    public Message saveOrUpdate(Comment comment){

        commentService.saveOrUpdate(comment);
        return MessageUtil.success("操作成功");
    }

    @ApiOperation("按id删除记录")
    @PostMapping("deleteById")
    public Message deleteById(long id){
        commentService.deleteById(id);
        return MessageUtil.success("删除成功");
    }
}
